package com.snk.back.controller;



import com.snk.back.service.SysRoleService;
import com.snk.common.pojo.JsonResult;
import com.snk.pojo.SysRole;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;


@RequestMapping("/role/")
@RestController
public class SysRoleController {


    @Autowired
    private SysRoleService sysRoleService;

    @RequestMapping("doFindPageObjects")
    public JsonResult doFindPageObjects(String name, Long pageCurrent){


        return new JsonResult(sysRoleService.findPageObjects(name,pageCurrent));
    }

    @RequestMapping("doDeleteObject")
    public JsonResult doDeleteObject(Integer id){
        sysRoleService.deleteObject(id);
        return new JsonResult("delete OK");
    }



    @RequestMapping("doSaveObject")
    public JsonResult doSaveObject(SysRole sysRole, Integer[] menuIds){
        sysRoleService.saveObject(sysRole, menuIds);
        return new JsonResult("Save OK");

    }

    @RequestMapping("doFindObjectById")
    public JsonResult doFindObjectById(Integer id){
        return new JsonResult(sysRoleService.findObjectById(id));
    }

    @RequestMapping("doUpdateObject")
    public JsonResult doUpdateObject(SysRole sysRole, Integer[] menuIds){
        sysRoleService.updateObject(sysRole,menuIds);
        return new JsonResult("Update OK");
    }


    @RequestMapping("doFindRoles")
    public JsonResult doFindRoles(){
        return new JsonResult(sysRoleService.findObjects());
    }

}
